﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameBase
{
    public class Camara
    {
        protected Matrix viewMatrix = Matrix.Identity;
        protected Matrix projectionMatrix = Matrix.Identity;

        public Camara()
        {

        }

        public void SetProjection(float FieldOfView, float AspectRatio, float NearPlaneDistance, float FarPlaneDistance)
        {
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(FieldOfView, AspectRatio, NearPlaneDistance, FarPlaneDistance);
        }
        public void SetView(Vector3 CameraPosition, Vector3 CameraTarget, Vector3 CameraUpVector)
        {
            viewMatrix = Matrix.CreateLookAt(CameraPosition, CameraTarget, CameraUpVector);
        }

        public Vector3 Project(Vector3 position, Viewport viewport)
        {
            Vector3 newPosition = Vector3.Transform(position, viewMatrix);
            newPosition = Vector3.Transform(newPosition, projectionMatrix);
            return viewport.Project(position,projectionMatrix,viewMatrix,Matrix.Identity);
        }

    }
}
